//
//  YBPhotoCollectionViewCell.m
//  OurTourism
//
//  Created by 孟镇 on 15/12/7.
//  Copyright © 2015年 Devil_Coming. All rights reserved.
//

#import "YBPhotoCollectionViewCell.h"
#include "Header.h"
@interface YBPhotoCollectionViewCell ()
@property (nonatomic, strong)UIImageView *coverImg;
@property (nonatomic, strong)UILabel *titleLable;
@end
@implementation YBPhotoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.coverImg = [[UIImageView alloc]init];
        [self.contentView addSubview:self.coverImg];
        self.coverImg.contentMode = UIViewContentModeScaleAspectFill;
        self.coverImg.clipsToBounds = YES;
        
        self.titleLable = [[UILabel alloc]init];
        self.titleLable.numberOfLines = 2;
        [self.contentView addSubview:self.titleLable];
        self.titleLable.textColor = [UIColor darkGrayColor];
        self.titleLable.font = [UIFont systemFontOfSize:12];
       
    }
    return self;

}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    [self.coverImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView).offset(0);
        make.left.mas_equalTo(self.contentView).offset(0);
        make.size.mas_equalTo(CGSizeMake(layoutAttributes.size.width, 150));
    }];
   
    [self.titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(self.coverImg).offset(40);
        make.left.mas_equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(layoutAttributes.size.width - 20, 30));
    }];
}

- (void)setModel:(YBDestinationModel *)model
{
    _model = model;
    
    [self.coverImg sd_setImageWithURL:[NSURL URLWithString:model.index_cover]];
    self.titleLable.text = model.index_title;
    
    
}

@end
